#pragma once
#include <opencv2/opencv.hpp>
#include<iostream>

using namespace cv;

typedef uchar PixType;
typedef short CostType;
typedef short DispType;


static const int DEFAULT_RIGHT_BORDER = -1;

enum { NR = 16, NR2 = NR / 2 };

enum
{
	MODE_SGBM = 0,
	MODE_HH = 1,
	MODE_SGBM_3WAY = 2,
	MODE_HH4 = 3
};

//#define CV_SIMD128 1

struct StereoSGBMParams1
{
	StereoSGBMParams1()
	{
		minDisparity = numDisparities = 0;
		SADWindowSize = 0;
		P1 = P2 = 0;
		disp12MaxDiff = 0;
		preFilterCap = 0;
		uniquenessRatio = 0;
		speckleWindowSize = 0;
		speckleRange = 0;
		mode = MODE_SGBM;
	}

	StereoSGBMParams1(int _minDisparity, int _numDisparities, int _SADWindowSize,
		int _P1, int _P2, int _disp12MaxDiff, int _preFilterCap,
		int _uniquenessRatio, int _speckleWindowSize, int _speckleRange,
		int _mode)
	{
		minDisparity = _minDisparity;
		numDisparities = _numDisparities;
		SADWindowSize = _SADWindowSize;
		P1 = _P1;
		P2 = _P2;
		disp12MaxDiff = _disp12MaxDiff;
		preFilterCap = _preFilterCap;
		uniquenessRatio = _uniquenessRatio;
		speckleWindowSize = _speckleWindowSize;
		speckleRange = _speckleRange;
		mode = _mode;
	}

	int minDisparity;
	int numDisparities;
	int SADWindowSize;
	int preFilterCap;
	int uniquenessRatio;
	int P1;
	int P2;
	int speckleWindowSize;
	int speckleRange;
	int disp12MaxDiff;
	int mode;
};

class  my_sgbm
{
public:

	my_sgbm();
	void create();
	/*static Ptr<my_sgbm> create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3,
		int P1 = 0, int P2 = 0, int disp12MaxDiff = 0,
		int preFilterCap = 0, int uniquenessRatio = 0,
		int speckleWindowSize = 0, int speckleRange = 0,
		int mode = MODE_SGBM);*/
	StereoSGBMParams1 params;

	Mat Buffer;
	//static const int num_stripes = 4;
	//Mat buffers[num_stripes];

	int getMinDisparity();
	void setMinDisparity(int minDisparity);

	int getNumDisparities();
	void setNumDisparities(int numDisparities);

	int getBlockSize();
	void setBlockSize(int blockSize);

	int getSpeckleWindowSize();
	void setSpeckleWindowSize(int speckleWindowSize);

	int getSpeckleRange();
	void setSpeckleRange(int speckleRange);

	int getDisp12MaxDiff();
	void setDisp12MaxDiff(int disp12MaxDiff);

	int getPreFilterCap();
	void setPreFilterCap(int preFilterCap);

	int getUniquenessRatio();
	void setUniquenessRatio(int uniquenessRatio);

	int getP1();
	void setP1(int P1);

	int getP2();
	void setP2(int P2);

	int getMode();
	void setMode(int mode);

	/*void calcPixelCostBT1(const Mat& img1, const Mat& img2,const Mat &img1_c,const Mat &img2_c, int y,
		int minD, int maxD, CostType* cost,
		PixType* buffer, const PixType* tab,
		int tabOfs, int, int xrange_min, int xrange_max = DEFAULT_RIGHT_BORDER);*/


	void computeDisparitySGBM1_HH4(const Mat& img1, const Mat& img2, const Mat &img1_c, const Mat &img2_c,
		Mat& disp1, const StereoSGBMParams1& params,
		Mat& buffer);
	void compute1(InputArray leftarr, InputArray rightarr, InputArray leftarr_c, InputArray rightarr_c, OutputArray disparr);



};


